﻿@model WebSiteFool.Models.Comment
<script language="javascript" type="text/javascript">
    function clearTextArea() {
        document.getElementById("comment-text").innerHtml = "";
    }
</script>
@using (Ajax.BeginForm("Create", "Comment", new AjaxOptions() { HttpMethod = "Post", UpdateTargetId = "comment", InsertionMode = InsertionMode.Replace, OnSuccess = "clearTextArea" }))
{
    @Html.AntiForgeryToken()
    @Html.HiddenFor(m => m.Article.Id)
    <h3>
        Post a comment:</h3>
    <fieldset>
        <ul>
            <li>
                @if (User.Identity.IsAuthenticated)
                {
                    <span>Your name: @User.Identity.Name</span>
                }
                else
                {
                    <span>Log in: @Html.Partial("_LoginBar")</span> 
                }
            </li>
            <li>@Html.Label("Comment:")
                @Html.TextAreaFor(m => Model.Content, new { id = "comment-text" })
                <div>
                    @Html.ValidationMessageFor(m => m.Content)</div>
            </li>
        </ul>
    </fieldset>
                if (!User.Identity.IsAuthenticated)
                {
    <input type="submit" value="Submit" class="submit-button" disabled="disabled" /><span>Please
        log in to post a comment.</span>
                }
                else
                {
    <input type="submit" value="Submit" class="submit-button" />
                }
}